/*
 * uart.c
 *
 * Created: 3/17/2012 1:42:58 PM
 *  Author: Unithra.C
 */ 

#include <avr/io.h>

/*
Initialization of UART
*/

void InitUART( unsigned char baudrate )
{
	UBRRL = 51;                  /* Set the baud rate */
	UCSRB = ( (1<<RXEN) | (1<<TXEN) );  /* Enable UART receiver and transmitter */
}

/* Read and write functions */
unsigned char ReceiveByte( void )
{
	while ( !(UCSRA & (1<<RXC)) ) 	/* Wait for incomming data */
		;			                /* Return the data */
	return UDR;
}

void TransmitByte( unsigned char data )
{
	while ( !(UCSRA & (1<<UDRE)) )
		; 			                /* Wait for empty transmit buffer */
	UDR = data; 			        /* Start transmittion */
}

